function lop_ctdt()
{
donvi=document.getElementById("donvi").value;
khoahoc=document.getElementById("khoahoc").value;
songanh=document.getElementById("soluongnganh").value;
var mang="";    
for(h=0;h<songanh;h++){
    nganh=document.getElementById("nganh"+h);
    if(nganh.checked){
        mang=mang+nganh.value+",";
    }
}    
    
var httpxml;
try
  {
  // Firefox, Opera 8.0+, Safari
  httpxml=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
		  try
	 		{
			 httpxml=new ActiveXObject("Msxml2.XMLHTTP");
			}
  			catch (e)
			{
    			try
      		{
      		httpxml=new ActiveXObject("Microsoft.XMLHTTP");
     		 }
    			catch (e)
      		{
      		alert("Your browser does not support AJAX!");
      		return false;
      		}
    		}
  }
function stateck1() 
    {
        
    if(httpxml.readyState==4)
      {
        var myarray=eval(httpxml.responseText);
        // Before adding new we must remove previously loaded elements
        
            var myNode = document.getElementById("append");
                while (myNode.firstChild) {
                    myNode.removeChild(myNode.firstChild);
                }   
                j=0;
            for (i=0;i<myarray.length;i++)
                {
                var cb = document.createElement( "input" );
                var br = document.createElement("br");
                cb.type = "checkbox";
                cb.id = "id"+j;
                cb.name = "checklop[]";
                cb.value = myarray[i]+"|$$|"+myarray[i+1];
                cb.checked = true;
                i++;
                j++;                
                var text = document.createTextNode(myarray[i]);
                
                document.getElementById('append').appendChild( text );
                document.getElementById('append').appendChild( cb );
                document.getElementById('append').appendChild(br);    
                }
      }
    }   
       
var url="daotao/lop_ctdt.php";
url=url+"?ma_nganh="+mang+"&donvi="+donvi+"&namkhoahoc="+khoahoc;
url=url+"&sid="+Math.random();

httpxml.onreadystatechange=stateck1;
httpxml.open("GET",url,true);
httpxml.send(null);
  }

//----------------------------------------------------------------------------------------------------------------------
function khoamon($i)
{
    khoalich=document.getElementById("khoalich");
    if(!khoalich.checked){
        khoalich.checked=true;
        khoalichhoc();
    }
        
    khoa=document.getElementById("khoa"+$i);
    if(khoa.checked)
    {
        songanh=document.getElementById("soluongnganh").value;
        var mangnganh="";
        var mangtennganh="";    
        for(h=0;h<songanh;h++){
            nganh=document.getElementById("nganh"+h);
            tennganh=document.getElementById("tennganh"+h);
            if(nganh.checked){
                mangnganh=mangnganh+nganh.value+",";
                mangtennganh=mangtennganh+tennganh.value+", "
            }
        }
        $nganhluu=document.getElementById("nganhluu"+$i);
        $nganhluu.value=mangnganh;
      
        var manglop="";
        var tenlop="";
        var cha = document.getElementById("append");
        var list = cha.getElementsByTagName('input')
        
        for(g=0;g<list.length;g++){
          if(list[g].checked){
            mang=list[g].value.split("|$$|");
            manglop=manglop+"'"+mang[0]+"',";
            tenlop=tenlop+mang[1]+", "
          }
        }
        
        $lopluu=document.getElementById("lopluu"+$i);
        $lopluu.value=manglop;
        
        $monhoc=document.getElementById("monhoc"+$i);
        $monluu=document.getElementById("monluu"+$i);
        $monluu.value=$monhoc.value;
        $monhoc.disabled=true;
        
        $canbo=document.getElementById("canbo"+$i);
        $canboluu=document.getElementById("canboluu"+$i);
        $canboluu.value=$canbo.value;
        $canbo.disabled=true;
        
        
        
        $cathi=document.getElementById("cathi"+$i);
        $cathiluu=document.getElementById("cathiluu"+$i);
        $cathiluu.value=$cathi.value;
        $cathi.disabled=true;
        
        $cathi2=document.getElementById("cathi2"+$i);
        $cathiluu2=document.getElementById("cathiluu2"+$i);
        $cathiluu2.value=$cathi2.value;
        $cathi2.disabled=true;
        
        ngay1=document.getElementById("ngay1"+$i);
        ngay1.readOnly=true;
        
        ngay2=document.getElementById("ngay2"+$i);
        ngay2.readOnly=true;
        
        ngaythi=document.getElementById("ngaythi"+$i);
        ngaythi.readOnly=true;
        
        ngaythi2=document.getElementById("ngaythi2"+$i);
        ngaythi2.readOnly=true;
        
        $chitiet=document.getElementById("chitiet"+$i);
        $chitiet.innerHTML="<font color=red>Ngành học : </font>"+mangtennganh+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=red>Lớp : </font>"+ tenlop;
    }else{
        $monhoc=document.getElementById("monhoc"+$i);
        $monhoc.disabled=false;
        
        $canbo=document.getElementById("canbo"+$i);
        $canbo.disabled=false;
        
        $cathi=document.getElementById("cathi"+$i);
        $cathi.disabled=false;
        
        $cathi2=document.getElementById("cathi2"+$i);
        $cathi2.disabled=false;
        
        ngay1=document.getElementById("ngay1"+$i);
        ngay1.readOnly=false;
        
        ngay2=document.getElementById("ngay2"+$i);
        ngay2.readOnly=false;
        
        ngaythi=document.getElementById("ngaythi"+$i);
        ngaythi.readOnly=false;
        
        ngaythi2=document.getElementById("ngaythi2"+$i);
        ngaythi2.readOnly=false;
        
        $chitiet=document.getElementById("chitiet"+$i);
        $chitiet.innerHTML="";
        
        $lopluu=document.getElementById("lopluu"+$i);
        $lopluu.value="";
        
        $nganhluu=document.getElementById("nganhluu"+$i);
        $nganhluu.value="";
    }
    
    
} 

//---------------------------------------------------------------------------------------------------------------------------------------------------
function khoalichhoc(){
    khoalich=document.getElementById("khoalich");
    
    if(khoalich.checked){
        donvi=document.getElementById("donvi");
        dvhv=document.getElementById("dvhv");
        khoahoc=document.getElementById("khoahoc");
        
        donviluu=document.getElementById("donviluu");
        dvhvluu=document.getElementById("dvhvluu");
        khoahocluu=document.getElementById("khoahocluu");
        
        donviluu.value=donvi.value;
        dvhvluu.value=dvhv.value;
        khoahocluu.value=khoahoc.value;
        
        donvi.disabled=true;
        dvhv.disabled=true;
        khoahoc.disabled=true;
        
    }else{
        donviluu=document.getElementById("donviluu");
        dvhvluu=document.getElementById("dvhvluu");
        khoahocluu=document.getElementById("khoahocluu");
        
        donviluu.value="";
        dvhvluu.value="";
        khoahocluu.value="";
        
        donvi.disabled=false;
        dvhv.disabled=false;
        khoahoc.disabled=false;
        
        for(h=0;h<songanh;h++){
            nganh=document.getElementById("nganh"+h);
            nganh.checked=false;
        }
        var myNode = document.getElementById("append");
            while (myNode.firstChild) {
                myNode.removeChild(myNode.firstChild);
        }   
    }
}

//--------------------------------------------------------------------------------------------------------------------------














